package com.bw.shop2208a.utils

import android.content.Context
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.youth.banner.Banner
import com.youth.banner.loader.ImageLoader

object ImageLoad {
    @JvmStatic
    @BindingAdapter("img_url")
    fun loadImage(imageView: ImageView,url: String?){
        if (url!=null){
            Glide.with(imageView.context).load(url).into(imageView)
        }
    }
    @JvmStatic
    @BindingAdapter("banner_url")
    fun loadBanner(banner: Banner,list: MutableList<String>?){
        banner.setImageLoader(object :ImageLoader(){
                override fun displayImage(context: Context?, path: Any?, imageView: ImageView?) {
                    if (context!=null&&imageView!=null){
                        GlideUtils.loadImage(context,imageView,path.toString())
                    }
                }
            })
        if (list!=null){
            banner.update(list)
        }

    }
}